Skip to content

Add: directory attributes value validations#857

Merged
milov-dmitriy merged 19 commits into
devfrom
add_attr_validations_task_792
Dec 9, 2025
Merged

Add: directory attributes value validations#857
milov-dmitriy merged 19 commits into
devfrom
add_attr_validations_task_792

Conversation

@milov-dmitriy
Copy link
Copy Markdown
Collaborator

@milov-dmitriy milov-dmitriy commented Dec 4, 2025

Задача: 792

Нужно реализовать поддерживаемую и расширяемую валидацию значений атрибутов любой директории согласно бизнес логике AD, правило валидации рассчитывается исходя из пары: Имя сущности (к которой относится директория) + Имя атрибута

Сделано:

  • добавлен класс валидации значений атрибутов директорий для LDAP запросов: add, modify, modifyDn
  • написаны тесты на сам валидатор значений
  • расширены тесты для add запроса

@milov-dmitriy milov-dmitriy requested a review from Copilot December 4, 2025 11:40
@milov-dmitriy milov-dmitriy self-assigned this Dec 4, 2025
@milov-dmitriy milov-dmitriy added python Pull requests that update Python code ldap labels Dec 4, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements comprehensive validation for directory attribute values in LDAP operations according to Active Directory business logic. The validation rules are determined by the combination of entity type name and attribute name.

  • Added AttributeValueValidator class with validation rules for directory attributes across add, modify, and modifyDn LDAP operations
  • Introduced EntityTypeNames enum to standardize entity type references throughout the codebase
  • Integrated validation into DAOs, gateways, and LDAP request handlers with proper error handling

Reviewed changes

Copilot reviewed 35 out of 35 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
app/enums.py Added EntityTypeNames enum defining standard entity type constants
app/ldap_protocol/ldap_schema/attribute_value_validator.py New validator class implementing business logic rules for attribute values
app/ldap_protocol/ldap_requests/add.py Integrated validation for LDAP add operations with error handling
app/ldap_protocol/ldap_requests/modify.py Added validation to modify operations
app/ldap_protocol/ldap_requests/modify_dn.py Added validation to modifyDn operations
app/ldap_protocol/ldap_requests/contexts.py Extended request contexts to include validator dependency
app/ldap_protocol/ldap_schema/entity_type_dao.py Injected validator and applied validation during entity type operations
app/ldap_protocol/policies/password/dao.py Added validator dependency for password attribute validation
app/ldap_protocol/auth/setup_gateway.py Integrated validator into setup operations
app/ioc.py Registered AttributeValueValidator in dependency injection container
tests/test_ldap/test_attribute_value_validator.py Comprehensive test suite for validator covering all validation rules
tests/test_api/test_main/test_router/test_add.py Extended tests to verify validation behavior in add operations
Multiple test files Updated to use EntityTypeNames enum instead of string literals
app/constants.py Updated entity type data structures to use EntityTypeNames enum
app/repo/pg/tables.py Added database indexes for performance optimization

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/ldap_protocol/ldap_schema/attribute_value_validator.py Outdated
Comment thread app/ldap_protocol/ldap_schema/attribute_value_validator.py Outdated
Comment thread app/ldap_protocol/auth/setup_gateway.py Outdated
Comment thread app/ldap_protocol/auth/setup_gateway.py Outdated
Comment thread app/ldap_protocol/ldap_schema/attribute_value_validator.py Outdated
Comment thread app/ldap_protocol/ldap_schema/attribute_value_validator.py Outdated
Comment thread docker-compose.test.yml Outdated
@milov-dmitriy milov-dmitriy requested a review from Copilot December 4, 2025 11:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 34 out of 34 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/ldap_protocol/ldap_requests/modify_dn.py Outdated
Comment thread app/ldap_protocol/ldap_requests/modify.py Outdated
Comment thread app/ldap_protocol/ldap_requests/add.py Outdated
Comment thread app/constants.py Outdated
@milov-dmitriy milov-dmitriy requested a review from Copilot December 4, 2025 12:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 34 out of 34 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/ldap_protocol/ldap_requests/modify_dn.py Outdated
Comment thread app/ldap_protocol/ldap_requests/modify.py Outdated
Comment thread app/ldap_protocol/utils/queries.py Outdated
Comment thread tests/test_api/test_main/test_router/test_add.py
@milov-dmitriy milov-dmitriy requested a review from Copilot December 4, 2025 12:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 34 out of 34 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/conftest.py Outdated
Comment thread app/ldap_protocol/ldap_schema/attribute_value_validator.py Outdated
Comment thread app/ldap_protocol/ldap_schema/attribute_value_validator.py
@Naksen Naksen self-requested a review December 4, 2025 12:39
Comment thread app/enums.py
Comment thread app/ldap_protocol/ldap_requests/add.py Outdated
Comment thread app/ldap_protocol/ldap_requests/modify.py Outdated
Comment thread app/ldap_protocol/ldap_requests/add.py Outdated
Comment thread app/ldap_protocol/ldap_requests/modify_dn.py Outdated
Comment thread app/ldap_protocol/ldap_requests/modify_dn.py Outdated
Comment thread app/ldap_protocol/ldap_schema/attribute_value_validator.py
Comment thread app/repo/pg/tables.py
@milov-dmitriy
Copy link
Copy Markdown
Collaborator Author

p.s. в ТестКлассах надо сделать свойство для хранения entity_type_name

@milov-dmitriy milov-dmitriy requested review from Mastermind-U, Naksen and Copilot and removed request for Copilot December 5, 2025 15:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 35 out of 35 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (1)

app/constants.py:1

  • Removed type ignore comments that are no longer necessary with proper typing.
"""Data variables.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/ldap_protocol/ldap_schema/attribute_value_validator.py Outdated
Comment thread tests/conftest.py
Comment thread app/ldap_protocol/utils/queries.py Outdated
Comment thread app/ldap_protocol/policies/password/dao.py Outdated
Comment thread app/ldap_protocol/ldap_schema/entity_type_dao.py Outdated
Comment thread app/repo/pg/tables.py
@milov-dmitriy
Copy link
Copy Markdown
Collaborator Author

milov-dmitriy commented Dec 5, 2025

!!! NOTE: После того как будет аппрув, нужно будет поменять целевую ветку с main на dev, сейчас это делать нельзя - можно потерять комментарии коммиты

Comment thread app/ldap_protocol/ldap_requests/add.py Outdated
Comment thread app/ldap_protocol/ldap_requests/modify.py Outdated
Comment thread app/ldap_protocol/ldap_schema/attribute_value_validator.py
Comment thread app/ldap_protocol/ldap_schema/attribute_value_validator.py Outdated
Comment thread app/ldap_protocol/ldap_schema/attribute_value_validator.py Outdated
Comment thread app/ldap_protocol/ldap_schema/attribute_value_validator.py Outdated
Comment thread app/entities.py Outdated
@milov-dmitriy milov-dmitriy changed the base branch from main to dev December 9, 2025 07:31
@milov-dmitriy milov-dmitriy merged commit 41e458f into dev Dec 9, 2025
4 checks passed
@milov-dmitriy milov-dmitriy deleted the add_attr_validations_task_792 branch December 9, 2025 07:33
rimu-stack added a commit that referenced this pull request Jan 28, 2026
* Add: directory attributes value validations (#857)

* Add: addRequest validate `new_name` (#862)

* fix: update push branch from main to dev in build workflow (#866)

* Http codes with map 774 (#836)

* Added dishka container to migrations (#868)

* Refactor: integrate NetworkPolicyGateway into LDAP session management (#863)

* Add default admin name 1111 (#872)

* Refactor syslog-ng configuration and enhance SyslogSender class (#871)

* Refactor: git checks (#869)

* Add: global LDAP server (#875)

* Fix: global ldap server (#877)

* Rework dependencies initialization in migrations (#880)

* add: UDP port mapping for LDAP service in docker-compose.yml (#882)

* Refactor ldap server (#867)

* Add: clear user password history (#874)

* Fix migration 275222846605 (#881)

* Add KRBAPIConnectionError handling to error map in krb5_router.py (#885)

* Add: directory is_system (#884)

* add: handling KRBAPIConnectionError in KerberosService exceptions (#886)

* Refactor: merge enterprise tests (#887)

* add: enqueue param for loguru (#888)

* Add: tmpfs and volume prune and kadmin_api depends on kdc (#891)

* New CI (#890)

* add: Contact entity type  (#896)

* refactor: rename services to System (#883)

* Hotfix262 (#898)

* Fix: user addRequest: recreate principal if exists already (#897)

* Enhance AddRequest: suppress KRBAPIPrincipalNotFoundError during principal deletion (#902)

* Refactor: cosmetic (#900)

* Add: Global Catalog logger (#892)

* Refactor: ModifyRequest (#893)

* Fix: Correct path assignment in _update_descendants function (#904)

* refactor: fix paths kadmin_api entrypoint (#903)

* add: rename services (#905)

* fix: replace services with system (#906)

---------

Co-authored-by: Milov Dmitriy <milovdd@mail.ru>
Co-authored-by: Ruslan <khannanov.rus@gmail.com>
Co-authored-by: Misha-Shvets <76677350+Misha-Shvets@users.noreply.github.com>
Co-authored-by: Михаил Михайлов <90135860+TheMihMih@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ldap python Pull requests that update Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants